function inserSort(arr=[]){
    let {length} = arr;
    //外层循环
    for(let i = 1;i<length;i++){
        let j = i; //待插入元素的下标
        let temp = arr[i]; //待插入的元素
        while(j>0 && arr[j-1] > temp){
            arr[j] = arr[j-1];
            j--;
        }

        arr[j] = temp;
    }
    return arr
}


console.log(inserSort([5,4,3,2,1]))